Apply a patch to reset the filter if an otherwise invisible file is
authorMatthias Clasen <mclasen@redhat.com>
Thu, 9 Dec 2004 22:06:55 +0000 (22:06 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 9 Dec 2004 22:06:55 +0000 (22:06 +0000)
2004-12-09  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkfilechooserdefault.c: Apply a patch to reset the
filter if an otherwise invisible file is selected via the
location popup.  (#159896, Carlos Garnacho Parro)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkfilechooserdefault.c

index e5e3fe2e3fe1be73e3ba55de707ff13edfe47323..84b8c220e97810d1929f693bc4eb1689e95c1e1a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2004-12-09  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkfilechooserdefault.c: Apply a patch to reset the 
+       filter if an otherwise invisible file is selected via the 
+       location popup.  (#159896, Carlos Garnacho Parro)
+
        Fix #145463, reported by Michael Natterer.
        
        * gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an
index e5e3fe2e3fe1be73e3ba55de707ff13edfe47323..84b8c220e97810d1929f693bc4eb1689e95c1e1a 100644 (file)
@@ -1,5 +1,9 @@
 2004-12-09  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkfilechooserdefault.c: Apply a patch to reset the 
+       filter if an otherwise invisible file is selected via the 
+       location popup.  (#159896, Carlos Garnacho Parro)
+
        Fix #145463, reported by Michael Natterer.
        
        * gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an
index e5e3fe2e3fe1be73e3ba55de707ff13edfe47323..84b8c220e97810d1929f693bc4eb1689e95c1e1a 100644 (file)
@@ -1,5 +1,9 @@
 2004-12-09  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkfilechooserdefault.c: Apply a patch to reset the 
+       filter if an otherwise invisible file is selected via the 
+       location popup.  (#159896, Carlos Garnacho Parro)
+
        Fix #145463, reported by Michael Natterer.
        
        * gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an
index e5e3fe2e3fe1be73e3ba55de707ff13edfe47323..84b8c220e97810d1929f693bc4eb1689e95c1e1a 100644 (file)
@@ -1,5 +1,9 @@
 2004-12-09  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkfilechooserdefault.c: Apply a patch to reset the 
+       filter if an otherwise invisible file is selected via the 
+       location popup.  (#159896, Carlos Garnacho Parro)
+
        Fix #145463, reported by Michael Natterer.
        
        * gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an
index 60bfad3f2f898dca14ede71ddbee53c7f94e04e6..ba7131402ef005a46c46508f3c300af5cde23f40 100644 (file)
@@ -3994,22 +3994,14 @@ gtk_file_chooser_default_screen_changed (GtkWidget *widget,
 }
 
 static gboolean
-list_model_filter_func (GtkFileSystemModel *model,
-                       GtkFilePath        *path,
-                       const GtkFileInfo  *file_info,
-                       gpointer            user_data)
+get_is_file_filtered (GtkFileChooserDefault *impl,
+                     GtkFilePath           *path,
+                     GtkFileInfo           *file_info)
 {
-  GtkFileChooserDefault *impl = user_data;
   GtkFileFilterInfo filter_info;
   GtkFileFilterFlags needed;
   gboolean result;
 
-  if (!impl->current_filter)
-    return TRUE;
-
-  if (gtk_file_info_get_is_folder (file_info))
-    return TRUE;
-
   filter_info.contains = GTK_FILE_FILTER_DISPLAY_NAME | GTK_FILE_FILTER_MIME_TYPE;
 
   needed = gtk_file_filter_get_needed (impl->current_filter);
@@ -4042,18 +4034,48 @@ list_model_filter_func (GtkFileSystemModel *model,
   if (filter_info.uri)
     g_free ((gchar *)filter_info.uri);
 
-  return result;
+  return !result;
+}
+
+static gboolean
+list_model_filter_func (GtkFileSystemModel *model,
+                       GtkFilePath        *path,
+                       const GtkFileInfo  *file_info,
+                       gpointer            user_data)
+{
+  GtkFileChooserDefault *impl = user_data;
+
+  if (!impl->current_filter)
+    return TRUE;
+
+  if (gtk_file_info_get_is_folder (file_info))
+    return TRUE;
+
+  return !get_is_file_filtered (impl, path, (GtkFileInfo *) file_info);
 }
 
 static void
 install_list_model_filter (GtkFileChooserDefault *impl)
 {
+  GtkFileSystemModelFilter filter;
+  gpointer data;
+
   g_assert (impl->browse_files_model != NULL);
 
   if (impl->current_filter)
-    _gtk_file_system_model_set_filter (impl->browse_files_model,
-                                      list_model_filter_func,
-                                      impl);
+    {
+      filter = list_model_filter_func;
+      data   = impl;
+    }
+  else
+    {
+      filter = NULL;
+      data   = NULL;
+    }
+  
+  _gtk_file_system_model_set_filter (impl->browse_files_model,
+                                    filter,
+                                    data);
 }
 
 #define COMPARE_DIRECTORIES                                                                                   \
@@ -4535,7 +4557,7 @@ gtk_file_chooser_default_select_path (GtkFileChooser    *chooser,
       gboolean result;
       GtkFileFolder *folder;
       GtkFileInfo *info;
-      gboolean is_hidden;
+      gboolean is_hidden, is_filtered;
 
       result = _gtk_file_chooser_set_current_folder_path (chooser, parent_path, error);
 
@@ -4557,12 +4579,16 @@ gtk_file_chooser_default_select_path (GtkFileChooser    *chooser,
       if (!info)
        return FALSE;
 
-      is_hidden = gtk_file_info_get_is_hidden (info);
+      is_hidden   = gtk_file_info_get_is_hidden (info);
+      is_filtered = get_is_file_filtered (impl, (GtkFilePath *) path, info);
       gtk_file_info_free (info);
 
       if (is_hidden)
        g_object_set (impl, "show-hidden", TRUE, NULL);
 
+      if (is_filtered)
+       set_current_filter (impl, NULL);
+
       pending_op_queue (impl, PENDING_OP_SELECT_PATH, path);
       return TRUE;
     }
@@ -5285,10 +5311,10 @@ set_current_filter (GtkFileChooserDefault *impl,
     {
       int filter_index;
 
-      /* If we have filters, new filter must be one of them
+      /* NULL filters are allowed to reset to non-filtered status
        */
       filter_index = g_slist_index (impl->filters, filter);
-      if (impl->filters && filter_index < 0)
+      if (impl->filters && filter && filter_index < 0)
        return;
 
       if (impl->current_filter)